#include<stdio.h>
#include<unistd.h>
#if 0
int main(){
    printf("begin\n");
    pid_t pid = fork();
    printf("end\n");
    return 0;
}
#endif

int main(){   
    pid_t pid = fork();
    if(pid < 0){
        printf("create sub process failed\n");
        return 0;
    }else if(pid == 0){
        //child
        printf("i am child: pid = %d, ppid = %d\n", getpid(), getppid());
    }else{
        //father
        while(1){
            printf("i am father: pid = %d, ppid = %d\n", getpid(), getppid());
            sleep(1);
        }
    }
    return 0;
}
